#ifndef MNHEAP_H
#define MNHEAP_H

typedef bool (*heapcmpfun)(int pre, int next);

class mn_heap
{
public:
    void build_mnheap_byrecurse(int *start, int *end, heapcmpfun cmp);
    void build_mnheap_byrecurse(int *start, int *end);

    void build_mnheap(int *start, int *end, heapcmpfun cmp);
    void build_mnheap(int *start, int *end);

    void push_mnheap(int *start, int *end, heapcmpfun cmp);
    void push_mnheap(int *start, int *end);

    void sort_mnheap(int *start, int *end, heapcmpfun cmp);
    void sort_mnheap(int *start, int *end);

    void print_mnheap(int *start, int *end);

    void pop_mnheap(int *start, int *end, heapcmpfun cmp);
    void pop_mnheap(int *start, int *end);

private:
    inline int get_left(int i);
    inline int get_right(int i);
    inline int get_parent(int i);

    inline bool default_cmp(int pre, int next);
};

void test_heap(void);

#endif // MNHEAP_H
